
<?php 

include_once '../../function.php';

// var_dump($_FILES);exit;

// if(!empty($_FILES)){

// 	$upload = current($_FILES);

// 	if($upload['error']==0){

// 		$allowType = ['jpg','png','gif'];

// 		$fileType = explode('.', $upload['name']);

// 		$fileType = end($fileType);

// 		if(in_array($fileType , $allowType )){

// 			is_dir('./Images') ||  mkdir('./Images');

// 			$name = uniqid();

// 			if(move_uploaded_file($upload['tmp_name'],'./Images/'.$name.'.'.$fileType)){
// 				echo "上传成功";
// 			}else{
// 				echo "上传失败,新重新上传";
// 			}
// 		}else{
// 			echo "上传失败,类型不允许";
// 		}

// 	}else{
// 		echo "上传失败,错误代码：".$upload['error'];
// 	}

// }else{
// 	echo "上传失败";
// }


if(empty($_FILES)){
	echo "上传失败";exit;
}

$upload = current($_FILES);

if($upload['error']>0){
	echo "上传失败,错误代码：".$upload['error'];
	exit;
}

$allowType = ['jpg','png','gif'];

$fileType = explode('.', $upload['name']);

$fileType = end($fileType);

if(!in_array($fileType , $allowType )){
	echo "上传失败,类型不允许";
	exit;
}

is_dir('./Images') ||  mkdir('./Images');

$name = uniqid();

if(move_uploaded_file($upload['tmp_name'],'./Images/'.$name.'.'.$fileType)){
	echo "上传成功";
}else{
	echo "上传失败,新重新上传";
}






















 ?>